package com.jianganming.observer.demo2;

import com.jianganming.observer.demo.Observer;
import com.jianganming.observer.demo.Subject;

//Subject：自定义广播抽象类
//广播对象
public class Teacher extends Subject {

    private String message;


    public Teacher(String name,String message) {
        super(name);
        this.message = message;
    }


    public String getMessage() {
        return message;
    }

    @Override
    public void notifyObserver(Subject subject) {
        Teacher teacher = (Teacher)subject;
        System.out.println(teacher.getName()+"通知："+teacher.getMessage());
        for (Observer observer : this.observers) {
            observer.response(subject);//通知所有学生
        }
    }
}
